package algorithm.leetcode.simple;

/*
 给定一个非空整数数组，除了某个元素只出现一次以外，其余每个元素均出现两次。找出那个只出现了一次的元素。
 */

/**
 * @author jack.wu
 * @version 1.0
 * @date 2020/10/15
 */
public class Question136 {

    public static void main(String[] args) {
        int[] nums = {2,2,1};
        Question136 question = new Question136();
        int singleNumber = question.singleNumber(nums);
        System.out.println(singleNumber);
    }

    public int singleNumber(int[] nums) {
        int singleNum = 0;
        for (int num : nums) {
            singleNum ^= num;
        }
        return singleNum;
    }
}
